```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>O(1)时间获取栈最小元素 | 算法可视化</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .stack-visual {
            transition: all 0.3s ease;
        }
        .stack-visual:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .footer-link:hover {
            color: #a777e3 !important;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">O(1)时间获取栈最小元素</h1>
            <p class="text-xl md:text-2xl mb-8 font-light opacity-90">优雅的数据结构设计实现极速最小值查询</p>
            <div class="flex justify-center space-x-4">
                <div class="bg-white bg-opacity-20 px-6 py-2 rounded-full flex items-center">
                    <i class="fas fa-lightbulb mr-2"></i>
                    <span>算法优化</span>
                </div>
                <div class="bg-white bg-opacity-20 px-6 py-2 rounded-full flex items-center">
                    <i class="fas fa-project-diagram mr-2"></i>
                    <span>双栈结构</span>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="prose max-w-none mx-auto">
                <p class="text-lg text-gray-700 leading-relaxed">
                    在算法设计中，我们经常需要在栈数据结构的基础上实现额外的功能。本案例展示了如何设计一个能够在常数时间O(1)内返回当前栈中最小元素的特殊栈结构。通过巧妙地使用辅助栈来跟踪最小值，我们实现了所有操作（push、pop、top、getMin）的时间复杂度均为O(1)。
                </p>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">双栈结构可视化</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="stack-visual bg-white p-6 rounded-xl shadow-lg border border-gray-100">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-layer-group text-blue-500 mr-2"></i>
                        主栈 (mainStack)
                    </h3>
                    <div class="flex flex-col items-center">
                        <div class="w-24 h-12 bg-gray-200 flex items-center justify-center border border-gray-300 rounded-t-lg">5</div>
                        <div class="w-24 h-12 bg-gray-100 flex items-center justify-center border border-gray-300">8</div>
                        <div class="w-24 h-12 bg-gray-200 flex items-center justify-center border border-gray-300">3</div>
                        <div class="w-24 h-12 bg-gray-100 flex items-center justify-center border border-gray-300">7</div>
                        <div class="w-24 h-12 bg-blue-100 flex items-center justify-center border border-blue-300 rounded-b-lg">2</div>
                    </div>
                </div>
                <div class="stack-visual bg-white p-6 rounded-xl shadow-lg border border-gray-100">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-filter text-purple-500 mr-2"></i>
                        辅助栈 (minStack)
                    </h3>
                    <div class="flex flex-col items-center">
                        <div class="w-24 h-12 bg-purple-50 flex items-center justify-center border border-purple-300 rounded-t-lg">5</div>
                        <div class="w-24 h-12 bg-purple-50 flex items-center justify-center border border-purple-300">3</div>
                        <div class="w-24 h-12 bg-purple-100 flex items-center justify-center border border-purple-400 font-bold rounded-b-lg">2</div>
                    </div>
                </div>
            </div>
            <div class="mt-8 text-center">
                <p class="text-gray-600 max-w-2xl mx-auto">
                    <i class="fas fa-info-circle text-blue-500 mr-1"></i>
                    辅助栈只存储主栈中曾经成为最小值的元素，这样栈顶永远保持当前最小值
                </p>
            </div>
        </section>

        <!-- Concept Diagram -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">算法流程示意图</h2>
            <div class="bg-white p-6 rounded-xl shadow-lg">
                <div class="mermaid">
                    graph TD
                        A[push操作] --> B[元素压入主栈]
                        B --> C{新元素 ≤ 辅助栈顶?}
                        C -->|是| D[压入辅助栈]
                        C -->|否| E[不操作]
                        F[pop操作] --> G[主栈弹出元素]
                        G --> H{弹出元素 = 辅助栈顶?}
                        H -->|是| I[辅助栈弹出]
                        H -->|否| J[不操作]
                        K[getMin操作] --> L[返回辅助栈顶]
                </div>
            </div>
        </section>

        <!-- Implementation Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">实现代码</h2>
            <div class="code-block text-gray-200 p-6 overflow-x-auto">
                <pre><code class="language-java">
import java.util.Stack;

class MinStack {
    private Stack&lt;Integer&gt; mainStack; // 主栈
    private Stack&lt;Integer&gt; minStack;   // 辅助栈，用于存储最小值

    public MinStack() {
        mainStack = new Stack&lt;&gt;();
        minStack = new Stack&lt;&gt;();
    }

    // 将元素推入栈中
    public void push(int x) {
        mainStack.push(x);
        // 如果辅助栈为空，或者新元素小于等于当前最小值，则将其压入辅助栈
        if (minStack.isEmpty() || x &lt;= minStack.peek()) {
            minStack.push(x);
        }
    }

    // 移除栈顶元素
    public void pop() {
        if (!mainStack.isEmpty()) {
            int top = mainStack.pop();
            // 如果弹出的元素是当前最小值，也将其从辅助栈中弹出
            if (top == minStack.peek()) {
                minStack.pop();
            }
        }
    }

    // 获取栈顶元素
    public int top() {
        if (!mainStack.isEmpty()) {
            return mainStack.peek();
        }
        throw new IllegalStateException("Stack is empty");
    }

    // 获取最小元素
    public int getMin() {
        if (!minStack.isEmpty()) {
            return minStack.peek();
        }
        throw new IllegalStateException("Stack is empty");
    }
}
                </code></pre>
            </div>
        </section>

        <!-- Complexity Analysis -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">时间复杂度分析</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-lg">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-tachometer-alt text-green-500 mr-2"></i>
                        操作效率
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>push操作</strong>: O(1) - 新元素的插入及最小值的维护都是常数时间操作</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>pop操作</strong>: O(1) - 只需要检查辅助栈的栈顶是否与弹出的元素相等</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>top操作</strong>: O(1) - 直接返回主栈的栈顶元素</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>getMin操作</strong>: O(1) - 直接返回辅助栈的栈顶元素</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                        关键点解析
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-asterisk text-yellow-500 mt-1 mr-2 text-xs"></i>
                            <span>辅助栈的空间复杂度为O(n)，最坏情况下与主栈相同</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-asterisk text-yellow-500 mt-1 mr-2 text-xs"></i>
                            <span>在push操作中，当新元素等于当前最小值时也需要压入辅助栈</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-asterisk text-yellow-500 mt-1 mr-2 text-xs"></i>
                            <span>pop操作需要同步检查是否弹出的是最小值</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-asterisk text-yellow-500 mt-1 mr-2 text-xs"></i>
                            <span>这种设计可以扩展到其他类似需求，如O(1)获取最大值</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Application Scenarios -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center">应用场景</h2>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition-shadow">
                    <div class="text-blue-500 text-3xl mb-4">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2">实时监控系统</h3>
                    <p class="text-gray-600">在需要持续跟踪最小值的数据流中高效运作</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition-shadow">
                    <div class="text-purple-500 text-3xl mb-4">
                        <i class="fas fa-calculator"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2">算法竞赛</h3>
                    <p class="text-gray-600">快速解决需要频繁查询极值的栈相关问题</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition-shadow">
                    <div class="text-green-500 text-3xl mb-4">
                        <i class="fas fa-database"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2">数据处理管道</h3>
                    <p class="text-gray-600">在数据处理的中间阶段快速获取关键指标</p>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="text-center">
                <h3 class="text-xl font-semibold text-white mb-2">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="footer-link text-gray-400 hover:text-white transition-colors">http://www.yuque.com/jtostring</a>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```